package com.woniuxy.exception;

import com.woniuxy.util.ResponseCode;
import com.woniuxy.util.ResponseData;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class GlobalException {
    @ExceptionHandler(CustomException.class)
    public ResponseData<?> handleCustomException(CustomException ex) {
        ResponseCode errorCode = ex.getErrorCode();
        return ResponseData.fail(errorCode);
    }
//    @ExceptionHandler(Exception.class)
//    public ResponseData<?> handleException(Exception ex) {
//        return ResponseData.fail(ResponseCode.SYSTEM_ERROR);
//    }
}
